Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class NodaTime.​Text.​ParseResult<​T>
Assembly: NodaTime
Inheritance: object → ParseResult
The result of a parse operation.
Properties
public
T
Value
Gets the value from the parse operation if it was successful, or throws an exception indicating the parse failure
otherwise.
Remarks This method is exactly equivalent to calling the <see cref="M:NodaTime.Text.ParseResult`1.GetValueOrThrow" /> method, but is terser if the code is
already clear that it will throw if the parse failed.
Exception
Gets an exception indicating the cause of the parse failure.
Remarks This property is typically used to wrap parse failures in higher level exceptions.
public
bool
Success
Indicates whether the parse operation was successful.
Remarks This returns True if and only if fetching the value with the <see cref="P:NodaTime.Text.ParseResult`1.Value" /> property will return with no exception.
Methods
public
T
GetValueOrThrow​()
Gets the value from the parse operation if it was successful, or throws an exception indicating the parse failure
otherwise.
Returns The result of the parsing operation if it was successful.
Remarks
This method is exactly equivalent to fetching the <see cref="P:NodaTime.Text.ParseResult`1.Value" /> property, but more explicit in terms of throwing
an exception on failure.
public
ParseResult<​TTarget>
Convert​(System.​Func<​T, TTarget> projection)
Converts this result to a new target type, either by executing the given projection
for a success result, or propagating the exception provider for failure.
Returns A ParseResult for the target type, either with a value obtained by applying the specified
projection to the value in this result, or with the same error as this result.
projection
The projection to apply for the value of this result,
if it's a success result.
public
ParseResult<​TTarget>
ConvertError​()
Converts this result to a new target type by propagating the exception provider.
This parse result must already be an error result.
Returns A ParseResult for the target type, with the same error as this result.
public static
ParseResult<​T>
ForValue​(T value)
Produces a ParseResult which represents a successful parse operation.
Returns A ParseResult representing a successful parsing operation.
value
The successfully parsed value.
Remarks
When T is a reference type, <paramref name="value" /> should not be null,
but this isn't currently checked.
public static
ParseResult<​T>
ForException​(System.​Func<​System.​Exception> exceptionProvider)
Produces a ParseResult which represents a failed parsing operation.
Returns A ParseResult representing a failed parsing operation.
exceptionProvider
A delegate that produces the exception representing the error that
caused the parse to fail.
Remarks
This method accepts a delegate rather than the exception itself, as creating an
exception can be relatively slow: if the client doesn't need the actual exception, just the information
that the parse failed, there's no point in creating the exception.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object